/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.simulation.data.domain;

import lombok.Data;
import profile.hujia.simulation.data.config.SystemConfig;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * class info
 *
 * @author hujia
 * @date 2019-06-11 10:42
 */
@Data
public class SingleLabelArg {

    private HashMap<String, List<Double>> ratioMap;
    private HashMap<String, List<NumberRange>> rangeMap;
    private HashMap<String, List<String>> levelMap;

    public SingleLabelArg() {
        initRatioValues();
        initRangeValues();
        initLevelValues();
    }

    private void initLevelValues() {
        levelMap = new HashMap<>();
        for (int i = 0; i < SystemConfig.SINGLE_NAME.length; ++i) {
            String[] values = SystemConfig.PERSON_ATTRIBUTE_LEVEL[i].split(SystemConfig.SEPARATION_CHARACTER);
            List<String> levelList = Arrays.asList(values);
            levelMap.put(SystemConfig.SINGLE_NAME[i], levelList);
        }
    }

    private void initRatioValues() {
        ratioMap = new HashMap<>();
        for (int i = 0; i < SystemConfig.SINGLE_NAME.length; ++i) {
            List<Double> numberList = new ArrayList<>();
            String[] values = SystemConfig.PERSON_ATTRIBUTE_RATIO[i].split(SystemConfig.SEPARATION_CHARACTER);
            for (int j = 0; j < values.length; ++j) {
                numberList.add(Double.parseDouble(values[j]));
            }
            ratioMap.put(SystemConfig.SINGLE_NAME[i], numberList);
        }
    }

    private void initRangeValues() {
        rangeMap = new HashMap<>();
        for (int i = 0; i < SystemConfig.SINGLE_NAME.length; ++i) {
            List<NumberRange> rangeList = new ArrayList<>();
            String[] values = SystemConfig.SINGLE_ATTRIBUTE_RANGE[i].split(SystemConfig.SEPARATION_CHARACTER);
            for (int j = 0; j < values.length - 1; ++j) {
                rangeList.add(new NumberRange(Integer.parseInt(values[j]), Integer.parseInt(values[j + 1])));
            }
            rangeMap.put(SystemConfig.SINGLE_NAME[i], rangeList);
        }
    }
}
